package org.lg.web.controller;

import org.lg.config.*;
import org.lg.dto.BaseDto;
import org.lg.dto.MessageEnum;
import org.lg.entity.Clazz;
import org.lg.page.PageInfo;
import org.lg.service.ClazzService;
import org.lg.service.impl.ClazzServiceImpl;

/**
 * 学生类的控制器 门卫 对url的响应处理
 */
@Controller("/clazzController")
public class ClazzController {
    @Resource
    ClazzService clazzService;
    /**
     * 查询全部学生 示例 无参数方法
     * @return
     */
    @RequestMapping("/getClazzs")
    @ResponseBody
    public BaseDto getAllClazzs() throws Exception {
        return  clazzService.getAllClazzs();
    }

    @RequestMapping("/getClazzByPage")
    @ResponseBody
    public BaseDto getClazzByPage(@RequestBody PageInfo pageInfo) throws Exception {
        return  clazzService.getClazzByPage(pageInfo);
    }


    /**
     * 根据主键查询 示范简单参数
     * @param id
     * @return
     */
    @RequestMapping("/getClazzById/{id}")
    public BaseDto getClazzById(String id) throws Exception{
        System.out.println(id);
        BaseDto dto = new BaseDto(MessageEnum.GETTEACHERBYIDSUCCESS);
        return  dto;
    }
    /*

     */
    @RequestMapping("/addClazz")
    @ResponseBody
    public BaseDto addClazz(Clazz Clazz) throws Exception{
        System.out.println(Clazz);
        BaseDto dto = new BaseDto(MessageEnum.ADDTEACHERSUCCESS,Clazz);
        return  dto;
    }

    @RequestMapping("/editClazz")
    @ResponseBody
    public BaseDto editClazz(@RequestBody Clazz Clazz){
        System.out.println(Clazz);
        BaseDto dto = new BaseDto(MessageEnum.ADDTEACHERSUCCESS,Clazz);
        return  dto;
    }
    @RequestMapping("/cancelClazz")
    public BaseDto cancelClazz(String clazzJson){
        BaseDto dto = new BaseDto(MessageEnum.GETTEACHERBYIDSUCCESS);
        return  dto;
    }
}

